/*************************************************************************
    > File Name: devbtn.c
    > Author: klmyt
    > Created Time: 2025年02月08日 星期六 16时32分00秒
 ************************************************************************/

#include "devbtn.h"

typedef struct button {
	int gpio;
	char* name;
	int bindex;
}btn_t;

static btn_t btns[] = {
	{.gpio = PAD_GPIO_A + 28, .name = "button1", .bindex = 0},
	{.gpio = PAD_GPIO_B + 30, .name = "button2", .bindex = 1},
	{.gpio = PAD_GPIO_B + 31, .name = "button3", .bindex = 2},
	{.gpio = PAD_GPIO_B + 9,  .name = "button4", .bindex = 3}
};

typedef struct buttonInfo {
	btn_t* pbtns;
	int size;
}btninfo_t;

static btninfo_t info = {
	.pbtns=btns,
	.size = ARRAY_SIZE(btns)
};

static void button_release(struct device *dev) {
	printk("%s: date = %s, time = %s\n", __func__, __DATE__,__TIME__);
};

static struct platform_device pd = {
	.name = "mybtn",
	.id = -1,
	.dev = {
		.platform_data = &info,
		.release = button_release
	}
};


int button_init(void){
	platform_device_register(&pd);
	return 0;
};

void button_exit(void){
	platform_device_unregister(&pd);
};

module_init(button_init);
module_exit(button_exit);
MODULE_LICENSE("GPL");

